<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap-theme.min.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/icon.css"/>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		
		$("#deDiv").hide();
		if("${currentRole}"=="客户"){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/getCorderAction',
				dataType:'json',
				success:function(data){
					if(data=="0"){
						$("#deDiv").show();
					}else{
						window.parent.$.messager.alert('','存在未完成的订单，无法删除该账号',"error",function(){
							location.href="${pageContext.request.contextPath}/corder/currentorder.jsp";
						});
					}
				},
			})
		}else{
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/getSorderAction',
				dataType:'json',
				success:function(data){
					if(data=="0"){
						$("#deDiv").show();
					}else{
						window.parent.$.messager.alert('','存在未完成的订单，无法删除该账号',"error",function(){
							location.href="${pageContext.request.contextPath}/sorder/currentorder.jsp";
						});
					}
				},
			})
		}
		
		
	$("#conBtn").click(function(){
			var upsw = $("input[name='upsw']").val();
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/modifyIsDeleteAction',
				data:{'upsw':upsw},
				dataType:'json',
				success:function(data){
					if(data=="1"){
						window.parent.$.messager.alert('','该账号已删除，请重新登录',"error",function(){
							$.ajax({
								type:'post',
								url:'${pageContext.request.contextPath}/quitAction',
								dataType:'json',
								success:function(r){
									if(r=="1"){
										window.parent.location="${pageContext.request.contextPath}/login.jsp";
									}
								}
							})
						});	
					}else{
						$.messager.show({
							title:'提示',
							msg:'密码错误,请重新输入密码',
							timeout:2000,
							showType:'slide'
						});
					}
				}	
			})
			
		})
		
	})
</script>
<body>
	<div class="container-fluid">
		<div class="row">
		<div class="col-md-4"></div>
		<div class="col-md-4" id="deDiv">
			<form >
				<div class="input-group input-group-sm">
					<span class="input-group-addon">请输入密码：</span>
					<input type="password" class="form-control" name="upsw">
				</div>
				<button id="conBtn" type="button" class="btn btn-default">确定</button>
			</form>
		</div>
		<div class="col-md-4"></div>
		</div>
	</div>
</body>
</html>